package cn.iocoder.yudao.module.system.repository.mybatis.dao.mail;

import cn.iocoder.yudao.common.pojo.PageResult;
import cn.iocoder.yudao.core.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.core.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.repository.mybatis.domain.mail.MailTemplate;
import cn.iocoder.yudao.module.system.vo.mail.template.MailTemplatePageReqVO;
import org.apache.ibatis.annotations.Mapper;


@Mapper
public interface MailTemplateMapper extends BaseMapperX<MailTemplate> {

    default PageResult<MailTemplate> selectPage(MailTemplatePageReqVO pageReqVO) {
        return selectPage(pageReqVO, new LambdaQueryWrapperX<MailTemplate>()
                .eqIfPresent(MailTemplate::getStatus, pageReqVO.getStatus())
                .likeIfPresent(MailTemplate::getCode, pageReqVO.getCode())
                .likeIfPresent(MailTemplate::getName, pageReqVO.getName())
                .eqIfPresent(MailTemplate::getAccountId, pageReqVO.getAccountId())
                .betweenIfPresent(MailTemplate::getCreateTime, pageReqVO.getCreateTime()));
    }

    default Long selectCountByAccountId(Long accountId) {
        return selectCount(MailTemplate::getAccountId, accountId);
    }

    default MailTemplate selectByCode(String code) {
        return selectOne(MailTemplate::getCode, code);
    }

}
